package com.study.array;

import java.util.Arrays;

/**
 * @author ytj
 * @date 2021/12/27
 */
public class Method6 {
    public static void main(String[] args) {
        int[] nums={-7,-3,2,3,11};
        sortedSquares(nums);
        Arrays.stream(nums).forEach(System.out::println);
    }

    public static int[] sortedSquares(int[] nums) {
        for(int i=0;i<nums.length;i++){
            nums[i]=nums[i]*nums[i];
        }
        maopao(nums);
        return nums;
    }

    /**
     * 冒泡排序
     * */
    public static int[] maopao(int[] nums){
        int a=0;
        for(int i=0;i<nums.length;i++){
            for(int j=0;j<nums.length-i-1;j++){
                if(nums[j]>nums[j+1]){
                    a=nums[j];
                    nums[j]=nums[j+1];
                    nums[j+1]=a;
                }
            }
        }
        return nums;
    }




}
